﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" />
    <link href="/CSS/V3/animate.css" rel="stylesheet" />
    <link href="/CSS/V3/style.css" rel="stylesheet" />
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.css?v=4.3.0" rel="stylesheet">
    <link href="/CSS/V3/BaseClassV3.css" rel="stylesheet" />
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/Scripts/bootstrap.js"></script>
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <style>
        .pCard {
            float: none;
            display: inline-block;
            vertical-align: top;
            border: 1px solid #d7dce1;
            box-shadow: 0 0px 2px #d7dce1;
            background-color: #f9f9f7;
            position: relative;
            -webkit-transition: all .5s ease-in-out;
            -moz-transition: all .2s ease-in-out;
            transition: all .2s ease-in-out;
            min-width: 130px;
            margin: 9px 6px 9px 9px;
        }

        .faq-question {
            color: #808080;
        }

            .faq-question:hover {
                color: #808080;
            }


        .faq-answer {
            background: #FFFFFF;
        }

            .faq-answer:hover .btntool {
                visibility: visible;
            }

            .faq-answer .btntool {
                visibility: hidden;
            }

        .faq-item {
            padding: 5px;
        }

        .social-footer {
            border: none;
            background-color: #FFFFFF;
        }

        .panel-body {
            padding: 0px;
        }
    </style>
    <script>
        var model = avalon.define({
            $id: "CommonData",
            username: ComFunJS.getnowuser(),
            selGGType: "",
            curGGType: "",
            GGTypeData: [],
            CommonData: [],
            SearchContent: "",
            page: 0,
            totalCount: "",
            ReadUserList: [],
            completegg: function (action) {
                if (action == "add") {
                    $("#phead").eq(0).click();
                }
            },
            AddQYGG: function () {
                parent.ComFunJS.winviewform("/ViewV3/APPBaseView/APP_ADD_WF.html?FormCode=QYGG", "添加数据", "1000");
            },
            GetGGDataList: function (type) {
                model.curGGType = type;
                $.getJSON('/API/FTAPI.ashx?Action=GETUSERQYGGLIST', { P1: model.curGGType, P2: 1, content: model.SearchContent }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.totalCount = resultData.Result1 == 0 ? "" : resultData.Result1;
                        model.CommonData = resultData.Result;
                        model.selGGType = model.curGGType;
                        model.selSearContent = model.SearchContent; 
                        laypage({
                            cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                            pages: Math.ceil(parseInt(model.totalCount) * 1.0 / 8), //通过后台拿到的总页数
                            curr: 1, //初始化当前页
                            jump: function (e) { //触发分页后的回调
                                if (model.selGGType != model.curGGType || model.selSearContent != model.SearchContent) {
                                    e.curr = 1;
                                }
                                $.getJSON('/API/FTAPI.ashx?Action=GETUSERQYGGLIST', { P1: model.curGGType, P2: e.curr, content: model.SearchContent }, function (resultData) {
                                    model.CommonData = resultData.Result;
                                    model.selGGType = model.curGGType;
                                    model.selSearContent = model.SearchContent;
                                })
                            }
                        });
                    }
                })

            },
            DELQYGG: function (Id, rowNumber) {
                parent.ComFunJS.winconfirm("确认要删除么", function () {

                    $.post("/API/FTAPI.ashx", { Action: "DELQYGGBYID", P1: Id }, function (result) {
                        var jsonresult = $.parseJSON(result)
                        if ($.trim(jsonresult.ErrorMsg) != "") {
                            ComFunJS.winwarning(jsonresult.ErrorMsg);
                        } else {
                            model.CommonData.remove(model.CommonData[rowNumber]);
                            parent.ComFunJS.winsuccess("删除成功");
                        }
                    })
                }, function () { })
            }, EDITQYGG: function (ID) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=QYGG&pageType=edit&ID=" + ID, "修改数据", "1000", "");
            },
            //公告
            ViewQYGG: function (Id) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_QYGG_VIEW.html?ID=" + Id + "&pageType=view", "企业公告", "1000", "");
            },
            UpdateRead: function (item) {
                if (item.ReadUser.indexOf(model.username) < 0) {
                    $.post('/API/FTAPI.ashx?Action=UPDATEQYGGREADUSER', { "P1": item.ID }, function (result) {
                        var result = $.parseJSON(result);
                        if (!result.ErrorMsg == "") {
                            parent.ComFunJS.winwarning(result.ErrorMsg);
                        }
                    })
                }
            },
            AddPL: function (item, dom) {
                var plcontent = dom.val();
                if ($.trim(plcontent) == "") {
                    parent.ComFunJS.winwarning("请输入批注内容");
                    return;
                }
                $.post('/API/FTAPI.ashx?Action=ADDCOMENT', { "P1": plcontent, "MsgType": "QYGG", "MsgLYID": item.ID }, function (result) {
                    var result = $.parseJSON(result);
                    if (result.ErrorMsg == "") {
                        item.PLList.push(result.Result);
                        dom.val("")
                    }
                })
            },
            jptj: function (event, item, dom) {
                if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) {
                    model.AddPL(item, dom);
                }
            }

        });
        avalon.ready(function () {
            ComFunJS.initsetajax();
            //获取主要菜单
            $.getJSON('/API/FTAPI.ashx?Action=GETCOLUMNLIST', { P1: "6" }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.GGTypeData = resultData.Result;
                }
            })
            model.GetGGDataList('');
        })
    </script>
</head>
<body class="gray-bg " ms-controller="CommonData">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-3">
                <div class="float-e-margins">
                    <div class="ibox-content" style="border: none; border-right: 1px solid #e7eaec;" >
                        <div class="file-manager">
                            <div class="hr-line-dashed"></div>
                            <button class="btn btn-primary btn-block" ms-click="AddQYGG()">添加公告</button>
                            <div class="hr-line-dashed"></div>
                            <h5>显示：</h5>
                            <button class="btn  btn-sm" ms-class-1="btn-primary:model.curGGType==''" ms-class-2="btn-white:model.curGGType!=''" ms-click="GetGGDataList('')" type="button">全部公告</button>
                            <button class="btn  btn-sm" ms-class-1="btn-primary:item.TypeNO==model.curGGType" ms-class-2="btn-white:item.TypeNO!=model.curGGType" style="margin-right:5px;" type="button" ms-click="GetGGDataList(item.TypeNO)" ms-repeat-item="GGTypeData">{{item.TypeNO}}</button>
                            <div class="hr-line-dashed"></div>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-9" >
                <div>
                    <div class="pull-right mail-search">
                        <div class="input-group">
                            <input type="text" class="input form-control" ms-duplex="SearchContent" placeholder="输入标题查询">
                            <span class="input-group-btn">
                                <button type="button" class="btn btn btn-primary" ms-click="GetGGDataList('')"> <i class="fa fa-search"></i> 搜索</button>
                            </span>
                        </div>
                    </div>
                    <h2>
                        企业公告
                    </h2>
                    <div class="mail-tools tooltip-demo m-t-md">
                        <div class="btn-group pull-right">
                            <div id="pageDiv"></div>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                </div>
                <div class="faq-item" ms-repeat-item="CommonData" style="padding:0">
                    <div class="panel-collapse  faq-answer" style="font-size:14px;border:0;border-bottom: 1px solid #e7eaec;">
                        <div class="row">
                            <div class="col-md-8" ms-click="ViewQYGG(item.ID)">
                                <a class="btn btn-xs btn-danger pull-left">{{item.remark}}</a> <a data-toggle="collapse" id="phead" class="faq-question pull-left" style="margin-left:5px; font-weight:400;  font-size:16px;">{{item.GGTitle}}</a>
                            </div>
                            <div class="col-md-4 text-right">
                                <a class=" btn btn-primary btn-xs btntool" ms-click="EDITQYGG(item.ID)" ms-if="item.CRUser==username"><i class="fa fa-pencil"></i> 编辑 </a>
                                <a class="btn btn-danger btn-xs btntool" ms-click="DELQYGG(item.ID,$index)" style="margin-right:15px" ms-if="item.CRUser==username"><i class="fa fa-trash-o"></i> 删除 </a>
                                <a class="btndate">{{item.FBTime|date("yyyy-MM-dd")}}</a>
                                <!--<a class="btn btn-white btn-xs" ms-click="UpdateRead(item)" data-toggle="collapse" ms-attr-href="'#faq'+item.ID"><i class="fa fa-angle-down"></i> </a>-->
                            </div>
                        </div>
                        <div ms-attr-id="'faq'+item.ID" class="collapse" style="margin:0px 10px 0px;display:none">
                            <div style="margin-bottom:10px;">
                                <span class="font-noraml">发布人：<a>{{item.CRUserName}}</a></span>
                            </div>
                            <p ms-html="item.GGContent">
                            </p>
                            <label ms-if="item.FileList.length>0"> 附件：</label><a style="margin-left:10px" ms-repeat-files="item.FileList" target="_blank" download="filename" ms-attr-href="'/View/Common/DownLoadFile.aspx?MD5='+files.FileMD5">{{files.Name+'.'+files.FileExtendName}}</a>
                            <div class="panel blank-panel" style="margin-top:10px;">
                                <div class="panel-options">
                                    <ul class="nav nav-tabs">
                                        <li class="active">
                                            <a data-toggle="tab" ms-href="'#tab-'+item.ID+'1'">评论</a>
                                        </li>
                                        <li class="">
                                            <a data-toggle="tab" ms-href="'#tab-'+item.ID+'2'">已阅数<span class="label label-info" ms-if="item.ReadUser.split(',').length>0">{{item.ReadUser.split(',').length}}</span></a>
                                        </li>
                                    </ul>
                                </div>
                                <div class="panel-body">
                                    <div class="tab-content">
                                        <div ms-attr-id="'tab-'+item.ID+'1'" class="tab-pane active">
                                            <div class="social-footer">
                                                <div class="social-comment" ms-repeat-el="item.PLList">
                                                    <span class="pull-left">
                                                        <img alt="image" ms-attr-src="'/Upload/TX/'+el.CRUser+'.jpg'" style="width:32px;height:32px" onerror="javascript: this.src = '/images/TX/default.png'" />
                                                    </span>
                                                    <div class="media-body">
                                                        <a href="#">
                                                            {{el.CRUserName}}
                                                        </a> {{el.MSGContent}}
                                                        <br>-
                                                        <small class="text-muted"> {{el.CRDate|date("MM月dd日 HH:mm")}}</small>
                                                    </div>
                                                </div>
                                                <div class="social-comment">
                                                    <a href="" class="pull-left">
                                                        <img alt="image" ms-attr-src="'/Upload/TX/'+username+'.jpg'" style="width:32px;height:32px" onerror="javascript: this.src = '/images/TX/default.png'" />
                                                    </a>
                                                    <div class="media-body">
                                                        <div class="input-group">
                                                            <input type="text" class="form-control" ms-keypress="jptj(event,item,$(this))" placeholder="填写评论(按Ctrl+Enter直接提交)" />
                                                            <span class="input-group-btn">
                                                                <button type="button" class="btn btn btn-primary" autocomplete="off" ms-on-click="AddPL(item,$(this).parent().parent().find('input'))"> 添加评论</button>
                                                            </span>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div ms-attr-id="'tab-'+item.ID+'2'" class="tab-pane">
                                            <div class="pCard" style="min-width: 70px;height:30px;text-align: center; line-height:30px; vertical-align:middle; " ms-repeat-el="item.ReadUser.split(',')">
                                                {{ComFunJS.convertuser(el)}}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
